package com.jt.ktdemo.ui.setting

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.jt.ktdemo.R
import com.jt.ktdemo.databinding.ActivitySettingBinding
import com.jt.ktdemo.ui.changePwd.ChangePwdActivity
import com.jt.ktdemo.ui.forget.ForgetThePasswordActivity
import com.jt.ktdemo.ui.login.LoginActivity
import com.jt.ktdemo.ui.myinfo.MyInfoActivity
import com.jt.ktdemo.utils.SpUtils

class SettingActivity :AppCompatActivity(), View.OnClickListener {

    private lateinit var binding:ActivitySettingBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = DataBindingUtil.setContentView(this, R.layout.activity_setting)
        binding.activity = this
        initView()
    }

    private fun initView() {
        binding.ivModuleBack.setOnClickListener(this)
        binding.rlModuleChangePwd.setOnClickListener(this)
        binding.rlModuleMyInfo.setOnClickListener(this)
        binding.tvModuleLogout.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.ivModuleBack -> {
                finish()
            }
            R.id.rlModuleMyInfo -> {
                startActivity(Intent(this@SettingActivity, MyInfoActivity().javaClass))
            }
            R.id.rlModuleChangePwd -> {
                startActivity(Intent(this@SettingActivity, ForgetThePasswordActivity().javaClass))
            }
            R.id.tvModuleLogout->{
                startActivity(Intent(this@SettingActivity, LoginActivity().javaClass))
                SpUtils.clear(this)
                finish()
            }
        }
    }
}